#ifndef DEVICE_DS18B20_H
#define DEVICE_DS18B20_H
#include <Ticker.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define DS18B20_PIN              16    // GPIO16 <==> D0
#define TEMP_COLLECT_INTERVAL    1000  // 温度采集周期(ms)

class DS18B20Control { 
public:
    ~DS18B20Control();
    void init(void);
    float_t temperature() { return m_temperature; }
private:
    void readTempCallback(void);
private:
    Ticker *m_tempCollector{nullptr};
    OneWire m_onewire;
    DallasTemperature *m_ds18b20Ctl{nullptr};
    float_t m_temperature{0.};
};
#endif